package net.openl10n.api.document;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;

import net.openl10n.api.Namespaces;

@XmlType(name="contentAnnotationType", namespace=Namespaces.DOCUMENT)
public class TextFlowTarget {
	
	@XmlEnum(String.class)
	public static enum ContentState{
		@XmlEnumValue("new") New,
		@XmlEnumValue("leveraged") Leveraged,
		@XmlEnumValue("for-review") ForReview,
		@XmlEnumValue("approved") Final
	}
	
	private String id;
	private long version = 1;
	private ContentState state = ContentState.New;
	private String content;
	
	public TextFlowTarget() {
		// TODO Auto-generated constructor stub
	}
	
	public TextFlowTarget(Resource resource) {
		this.id = resource.getId();
		this.version = resource.getVersion();
	}
	
	@XmlAttribute(name="id", required=true)
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	@XmlAttribute(name="version", required=true)
	public long getVersion() {
		return version;
	}
	
	public void setVersion(long version) {
		this.version = version;
	}
	
	@XmlAttribute(name="state", required=true)
	public ContentState getState() {
		return state;
	}
	
	public void setState(ContentState state) {
		this.state = state;
	}
	
	@XmlElement(name="content",namespace=Namespaces.DOCUMENT, required=true)
	public String getContent() {
		if(content == null)
			return "";
		return content;
	}
	
	public void setContent(String content) {
		this.content = content;
	}
}
